home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
CRS
/
crs30.d81
/
bookboot
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2009-10-10
|
5KB
|
126 lines
3 REM: ********************************
4 REM: *MODIFIED BEYOND RECOGNITION BY*
5 REM: *LORD KATANA *
6 REM: * HAPPY HUNTING- *
7 REM: * LK 7-8-92 * 8 REM: ********************************
10 REM USE THIS PROGRAM TO LEARN HOW
20 REM CREATE AND USE RELATIVE FILES.
30 REM IT IS FLEXIBLE ENOUGH FOR YOU
40 REM TO CUSTOMIZE IT FOR YOUR USE.
50 REM
60 PRINT"[147]*RELATIVE FILE DEMO*"
70 LL$=CHR$(13) :REM THIS IS THE FIELD DELIMITER USED WHEN WRITING RECORDS
80 OPEN15,8,15,"I0":CLOSE15 : REM INITIALIZE THE DISK DRIVE.
90 INPUT"WHAT IS THE FILE NAME";NM$: REM MAXIMUM 16 CHARACTER NAME.
100 IFLEN(NM$)>0ANDLEN(NM$)<17THEN120
110 PRINT"[145][145][145]":GOTO90
120 INPUT"HOW MANY CHARACTERS IN EACH RECORD";LN :REM MAXIMUM 254.
130 LN=INT(LN):IFLN>0ANDLN<255THEN150
140 PRINT"[145][145][145]":GOTO120
150 PRINT
160 PRINT"DO YOU WANT TO"
170 PRINT"R[146]EAD A RECORD"
180 PRINT"W[146]RITE A RECORD"
190 PRINT"S[146]ET UP A FILE"
200 INPUT"OR Q[146]UIT";A$
210 IF A$="R" THEN 270
220 IF A$="W" THEN 510
230 IF A$="S" THEN 770
240 IF A$="Q" THEN 970
250 PRINT"TYPE AN 'R' 'W' 'S' OR 'Q' ":GOTO160
260 :
270 REM THIS SECTION POSITIONS TO AND READS A RECORD.
280 OPEN15,8,15 :REM OPEN THE COMMAND CHANNEL
290 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
300 OPEN8,8,8,"0:"+(NM$)+",L,"+CHR$(LN) :REM OPEN FILE WITH RECORD LENGTH LN.
310 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
320 INPUT"READ WHAT RECORD NUMBER";RN
330 GOSUB980 :REM CALCULATE THE LOW BYTE/HIGH BYTE POINTER.
340 PRINT#15,"P"+CHR$(96+8)+CHR$(RL)+CHR$(RH)+CHR$(1) :REM POSITION COMMAND
350 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
360 IF E=50 THENPRINT"RECORD NUMBER TOO LARGE":GOTO450
370 INPUT#8,AA$,BB$,CC$,DD$,EE$,FF$:REM READ IN THE FIELDS.
380 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
390 PRINT"RECORD NUMBER";RN;"CONTAINS:"
400 PRINT" NAME: ";AA$
410 PRINT" ADDRESS: ";BB$
420 PRINT" CITY: ";CC$
430 PRINT" STATE: ";DD$
440 PRINT"ZIP CODE: ";EE$
445 PRINT" PHONE: ";FF$
450 PRINT#15,"P"+CHR$(96+8)+CHR$(RL)+CHR$(RH)+CHR$(1):REM REPOSIT'N FOR SAFETY
460 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
470 INPUT"READ ANOTHER RECORD";A$
480 IF A$="Y"THEN320
490 CLOSE8:CLOSE15:GOTO160 :REM GO TO THE MENU
500 :
510 REM THIS SECTION POSITIONS TO AND WRITES A RECORD.
520 OPEN15,8,15 :REM OPEN THE COMMAND CHANNEL
530 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
540 OPEN8,8,8,"0:"+(NM$)+",L,"+CHR$(LN) :REM OPEN FILE WITH RECORD LENGTH LN.
550 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
560 INPUT"WRITE WHAT RECORD NUMBER";RN
570 INPUT"NAME";AA$ :REM CHANGE THE PROMPTS TO ASK FOR THE DATA NEEDED
580 INPUT"ADDRESS";BB$ :REM IN YOUR PARTICULAR APPLICATION.
590 INPUT"CITY";CC$ :REM ANY NUMBER OF FIELDS CAN BE USED AS LONG AS
600 INPUT"STATE";DD$ :REM THEY FIT WITHIN THE RECORD LENGTH YOU
610 INPUT"ZIP CODE";EE$ :REM SPECIFIED WHEN CREATING THE FILE.
615 INPUT" PHONE";FF$
620 RC$=AA$+LL$+BB$+LL$+CC$+LL$+DD$+LL$+EE$+LL$+FF$
630 REM RC$ IS THE STRING CONTAINING ALL THE FIELDS FOR THE RECORD.
640 REM REMEMBER THE MAX LENGTH FOR RC$ IS 254 CHARACTERS.
650 GOSUB980 :REM CALCULATE THE LOW BYTE/HIGH BYTE POINTER.
660 PRINT#15,"P"+CHR$(96+8)+CHR$(RL)+CHR$(RH)+CHR$(1) :REM POSITION COMMAND
670 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
680 IF E=50 THENPRINT"THE DOS WILL EXPAND THE FILE NOW"
690 PRINT#8,RC$ :REM WRITE THE RECORD
700 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
710 PRINT#15,"P"+CHR$(96+8)+CHR$(RL)+CHR$(RH)+CHR$(1) :REM REPOSIT'N FOR SAFETY
720 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
730 INPUT"WRITE ANOTHER RECORD";A$
740 IF A$="Y"THEN550
750 CLOSE8:CLOSE15:GOTO160 :REM GO TO THE MENU
760 :
770 REM THIS SECTION POSITIONS TO AND WRITES THE HIGHEST RECORD NUMBER.
780 REM ALTHOUGH NOT ENTIRELY NECESSARY, WRITING AND UPDATING LONG FILES
790 REM IS SPEEDED WHEN THIS PROCEDURE IS USED. THIS WILL CAUSE THE
800 REM DOS SIDE SECTOR LIST TO BE CREATED ENTIRELY AT THE START RATHER
810 REM THAN BEING APPENDED FOR EACH NEW HIGHER RECORD NUMBER.
820 OPEN15,8,15 :REM OPEN THE COMMAND CHANNEL
830 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
840 OPEN8,8,8,"0:"+(NM$)+",L,"+CHR$(LN) :REM OPEN FILE WITH RECORD LENGTH LN.
850 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
860 PRINT"WHAT IS THE HIGHEST RECORD NUMBER"
870 INPUT"YOU WANT TO USE";RN
880 GOSUB980 :REM CALCULATE THE LOW BYTE/HIGH BYTE POINTER.
890 PRINT#15,"P"+CHR$(96+8)+CHR$(RL)+CHR$(RH)+CHR$(1) :REM POSITION COMMAND
900 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
910 IF E=50 THENPRINT"THE DOS WILL EXPAND THE FILE NOW"
920 PRINT#8,CHR$(255) :REM
930 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
940 PRINT#15,"P"+CHR$(96+8)+CHR$(RL)+CHR$(RH)+CHR$(1) :REM REPOSIT'N FOR SAFETY
950 GOSUB 1030 :REM CHECK THE ERROR CHANNEL
960 CLOSE8:CLOSE15:GOTO160 :REM GO TO THE MENU
970 CLOSE8:CLOSE15:END
980 REM THIS SUBROUTINE CALCULATES THE RECORD NUMBER POINTER
990 REM IN THE LOW BYTE/HIGH BYTE FORMAT.
1000 REM RN (RECORD NUMBER) IS USED TO CALCULATE RL AND RH.
1010 RH=INT(RN/256):RL=RN-(256*RH) : REM RL IS LOW -- RH IS HIGH.
1020 RETURN
1030 REM THIS IS THE DISK DRIVE ERROR CHECKING SUBROUTINE.
1040 INPUT#15,E,E$,A,B :REM READ THE ERROR CHANNEL.
1050 IF E=0 THEN RETURN :REM THERE IS NO ERROR IF E=0.
1060 REM E=50 (RECORD NOT PRESENT) ANY TIME A RECORD NUMBER POINTER IS
1070 REM POSITIONED BEYOND THE CURRENT HIGHEST RECORD NUMBER.
1080 IF E=50 THEN RETURN
1090 IF E<>51 THEN 1130
1100 PRINT:PRINT"ERROR #51, RECORD TOO LONG."
1110 PRINT"MAXIMUM LENGTH IS"LN"CHARACTERS."
1120 PRINT"RETURN COUNTS AS A CHARACTER.":RETURN
1130 PRINT"THERE IS AN I/O PROBLEM"
1140 PRINT"ERROR NUMBER IS";E,E$
1150 PRINT"AT TRACK";A;" SECTOR";B
1160 IF E=70 THENPRINT"MAKE SURE YOU INPUT THE CORRECT RECORD"
1170 IF E=70 THENPRINT"LENGTH FOR AN EXISTING FILE NAME."
1180 CLOSE8:CLOSE15:END